package com.example.controller;

import com.example.pojo.LoginMsg;
import com.example.pojo.ScoreResult;
import com.example.pojo.Student;
import com.example.pojo.UpdateInfoResult;
import com.example.service.StudentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@CrossOrigin
@RestController
@RequestMapping("/updateStudentInfo")
public class StudentController {

    @Autowired
    private StudentService studentService;

    @PostMapping
    public UpdateInfoResult updateInfo(@RequestBody Student student)
    {
        log.info("更新信息"+student);
        LoginMsg loginMsg = studentService.updateInfo(student);
        if(loginMsg!=null&&loginMsg.getMsg()==null){
            return UpdateInfoResult.success(loginMsg);
        }else if(loginMsg==null){
            return UpdateInfoResult.fail("修改失败");
        }
        return UpdateInfoResult.fail(loginMsg.getMsg());
    }
}
